<template>
  <div>
    <van-field :label="lable" :type="type" :placeholder="placeholder" :rule="rule" v-model="content" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      content: ''
    }
  },
  props: ['lable', 'type', 'placeholder', 'rule'],
  created() {},
  methods: {
    inputChange() {
      const rules = new RegExp(this.rule)
      if (rules.test(this.content)) {
        // 子组件向父组件传值 通过自定义事件inputValue
        this.$emit('inputValue', this.content)
      }
    }
  },

  watch: {
    content() {
      this.inputChange()
    }
  }
}
</script>

<style lang="stylus" scoped></style>
